package com.futureway.test.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.futureway.test.entity.Course;
import com.futureway.test.service.CourseService;

import lombok.extern.slf4j.Slf4j;

@RestController
@RequestMapping("/course")
@Slf4j
public class CourseController {
	@Autowired
	private CourseService courseService;

	@GetMapping("/get/{id}")
	public Course get(@PathVariable Integer id) {
		log.error(">>>>测试error级别");
		log.debug(">>>>测试debug级别");
		log.info(">>>>测试info级别");
		log.warn(">>>>测试warn级别");
		return courseService.get(id);
	}

	@GetMapping("/list")
	public List<Course> list() {
		return courseService.findAll();
	}

	@PostMapping("/save")
	public Integer save(String courseName) {
		return courseService.save(courseName);
	}
}
